<template src="./dateYearMonth.html"></template>

<script>
export default {
  name: "TianDingDateYearMonthComponent",
  data() {
    return {
      date: {},
      dateSlots: [],
      load: false,
      value: ""
    };
  },
  mounted() {
    this.loaderDate();
  },
  methods: {
    loaderDate() {
      let startDate = new Date("2000-01");
      let endDate = new Date();
      console.log(startDate.getFullYear(), endDate.getFullYear());
      for (
        let index = parseInt(startDate.getFullYear());
        index <= parseInt(endDate.getFullYear());
        index++
      ) {
        this.date[index + "年"] = "";
      }
      let monthList = [];
      for (let index = 1; index <= 12; index++) {
        if (index < 10) {
          index = "0" + index;
        }
        monthList.push(index + "月");
      }
      this.dateSlots.push({
        flex: 1,
        values: Object.keys(this.date),
        className: "slot1",
        textAlign: "center"
      });
      this.dateSlots.push({
        divider: true,
        content: "-",
        className: "slot2"
      });
      this.dateSlots.push({
        flex: 1,
        values: monthList,
        className: "slot3",
        textAlign: "center"
      });
      this.load = true;
    },
    onChange(picker, values) {
      this.value = `${values[0]}${values[1]}`;
      this.$emit("changeEvent", this.value);
    }
  }
};
</script>
